<?php

namespace app\controller\tools;

use think\facade\Config;
use think\facade\Session as Server;


class Session extends Base
{
    
    // Session
    
    /**
     * 1、设置
     * 2、获取
     */
    
	// cookie
	// cookie 可以设置数组 也可以用 $_COOKIE 获取
	// http://www.light.com/tools/session/cookie
	public function cookie(){
		cookie('user[id]', 10, 3600);
		if (isset($_COOKIE['user']['id'])){
			var_dump($_COOKIE['user']['id']);
			var_dump($_COOKIE['user']);
		}
	}
	
    // 设置
    // http://www.light.com/tools/session/set
    public function set()
    {
        Server::set('name', 'thinkphp');
        
        return $this->success();
    }
    
    // 获取
    // http://www.light.com/tools/session/get
    public function get()
    {
        $name = Server::get('name');
        
        return $this->success([$name]);
    }
    
}
